import axios from "../utils/request";
import md5 from "md5";

export const $login = async (params) => {
  params.loginPwd = md5(md5(params.loginPwd).split("").reverse().join(""));
  let { data } = await axios.post("/login", { params });
  if (data.success) {
    sessionStorage.setItem("token", data.token);
  }
  return data;
};

export const $user = async () => {
  let { data } = await axios.get("/user");
  return data;
};

export const $adduser = async (params) => {
  let { data } = await axios.post("/adduser", { params });
  return data;
};

export const $role = async () => {
  let { data } = await axios.get("/role");
  return data;
};

export const $addrole = async (params) => {
  let { data } = await axios.post("/addrole", { params });
  return data;
};
